
from watchdog.observers import Observer
from watchdog.events import *
import random
import threading
import time
from tkinter import *
import tkinter

def dow():
    root = Tk()
    width = 380
    heigh = 300
    screenwidth = root.winfo_screenwidth()
    screenheight = root.winfo_screenheight()
    root.geometry('%dx%d+%d+%d'%(width, heigh, (screenwidth-width)/2, (screenheight-heigh)/2))
    te = tkinter.Label(root, text ='下载完成',        
    bg='Green', # 背景颜色
    font=('楷体', 17), # 字体和字体大小
    width=50, height=60 # 标签长宽
    )
    te.pack()
    mainloop()

class FileEventHandler(FileSystemEventHandler):
    def __init__(self):
        FileSystemEventHandler.__init__(self)

    def on_modified(self, event):
        if event.is_directory:
            print("directory modified:{0}".format(event.src_path))
        else:
            print("file modified:{0}".format(event.src_path))
            dow()

if __name__ == "__main__":
    while True:
        observer = Observer()
        event_handler = FileEventHandler()
        observer.schedule(event_handler, "C:/Users/dell/Desktop/WitinProgramTool_WTM1001(2)/program.log", True) #文件夹名
        observer.start()
        time.sleep(1)
        observer.join()
